library(foreign)
library(ggplot2)
library(tidyr)


# Figure 9: Attitudes on Risk and Instrumental Harm, Split into Quadrants
# Find out if quadrants are clockwise? Change Numbers to match

setwd("/Users/dmin/Dropbox/Replication_Data/Paper_2/")

Dat <- read.csv("Paper_2_Data_Clean.csv", stringsAsFactors = FALSE)

table(Dat$Quadrant_fac)

p <- ggplot(Dat, aes(x=(UtilAvg), y=(RiskAvg))) + 
  geom_point(position = position_jitter(width = 0.05, height = 0.01), alpha = 0.8) +
  geom_hline(yintercept=2.96) + geom_vline(xintercept=3.42) + ggtitle("") + theme_bw() +
  scale_color_discrete(name = "Preferred Theory", labels = c("Never Ever","Existential Deterrence", "Offense/Defense", "Utilitarian")) + xlab("Instrumental Harm") + 
  ylab("Risk Acceptance") + theme(plot.title = element_text(hjust = 0.5), plot.subtitle = element_text(hjust = 0.5)) 

p2<-p + annotate("rect", xmin=0.8, xmax=3.42, ymin=0.8, ymax =2.96, fill="green3", alpha=.2) +
  annotate("rect", xmin=0.8, xmax=3.42, ymin=2.96, ymax =7.2, fill="yellow3", alpha=.2) +
  annotate("rect", xmin=3.42, xmax=7.2, ymin=0.8, ymax =2.96, fill="orange3", alpha=.2) +
  annotate("rect", xmin=3.42, xmax=7.2, ymin=2.96, ymax =7.2, fill="red3", alpha=.2)

g<-p2+  annotate("text", y=0.5, x=2, label="Q3: Low Harm, Low Risk, n=404") +
  annotate("text", y=7.5, x=2, label="Q2: Low Harm, High Risk, n=128") +
  annotate("text", y=0.5, x=5, label="Q4: High Harm, Low Risk, n=217") +
  annotate("text", y=7.5, x=5, label="Q1: High Harm, Low Risk, n=289") 

g

ggsave("Image_9.png", plot=g, width=2000, height=2000, units=c("px"))


